package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecAttachment;
import org.ycx.upms.dao.model.SecAttachmentExample;

import java.util.List;

public interface SecAttachmentMapper {
    @SelectProvider(type=SecAttachmentSqlProvider.class, method="countByExample")
    long countByExample(SecAttachmentExample example);

    @DeleteProvider(type=SecAttachmentSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecAttachmentExample example);

    @Delete({
        "delete from sec_attachment",
        "where AID = #{aid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer aid);

    @Insert({
        "insert into sec_attachment (OBJECT_NAME, OBJECT_KEY, ",
        "NAME, MIME, FILE_DESC, ",
        "URI, CODE, CREATE_TS, ",
        "CREATE_UID, DEL_FLAG)",
        "values (#{objectName,jdbcType=VARCHAR}, #{objectKey,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{mime,jdbcType=VARCHAR}, #{fileDesc,jdbcType=VARCHAR}, ",
        "#{uri,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{createTs,jdbcType=DATE}, ",
        "#{createUid,jdbcType=INTEGER}, #{delFlag,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="aid", before=false, resultType=Integer.class)
    int insert(SecAttachment record);

    @InsertProvider(type=SecAttachmentSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="aid", before=false, resultType=Integer.class)
    int insertSelective(SecAttachment record);

    @SelectProvider(type=SecAttachmentSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="AID", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="OBJECT_NAME", property="objectName", jdbcType=JdbcType.VARCHAR),
        @Result(column="OBJECT_KEY", property="objectKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="MIME", property="mime", jdbcType=JdbcType.VARCHAR),
        @Result(column="FILE_DESC", property="fileDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="URI", property="uri", jdbcType=JdbcType.VARCHAR),
        @Result(column="CODE", property="code", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="DEL_FLAG", property="delFlag", jdbcType=JdbcType.VARCHAR)
    })
    List<SecAttachment> selectByExample(SecAttachmentExample example);

    @Select({
        "select",
        "AID, OBJECT_NAME, OBJECT_KEY, NAME, MIME, FILE_DESC, URI, CODE, CREATE_TS, CREATE_UID, ",
        "DEL_FLAG",
        "from sec_attachment",
        "where AID = #{aid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="AID", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="OBJECT_NAME", property="objectName", jdbcType=JdbcType.VARCHAR),
        @Result(column="OBJECT_KEY", property="objectKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="MIME", property="mime", jdbcType=JdbcType.VARCHAR),
        @Result(column="FILE_DESC", property="fileDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="URI", property="uri", jdbcType=JdbcType.VARCHAR),
        @Result(column="CODE", property="code", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="DEL_FLAG", property="delFlag", jdbcType=JdbcType.VARCHAR)
    })
    SecAttachment selectByPrimaryKey(Integer aid);

    @UpdateProvider(type=SecAttachmentSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecAttachment record, @Param("example") SecAttachmentExample example);

    @UpdateProvider(type=SecAttachmentSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecAttachment record, @Param("example") SecAttachmentExample example);

    @UpdateProvider(type=SecAttachmentSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecAttachment record);

    @Update({
        "update sec_attachment",
        "set OBJECT_NAME = #{objectName,jdbcType=VARCHAR},",
          "OBJECT_KEY = #{objectKey,jdbcType=VARCHAR},",
          "NAME = #{name,jdbcType=VARCHAR},",
          "MIME = #{mime,jdbcType=VARCHAR},",
          "FILE_DESC = #{fileDesc,jdbcType=VARCHAR},",
          "URI = #{uri,jdbcType=VARCHAR},",
          "CODE = #{code,jdbcType=VARCHAR},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "DEL_FLAG = #{delFlag,jdbcType=VARCHAR}",
        "where AID = #{aid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecAttachment record);
}